<template>
  <div>
    <!-- <ul>
      <li v-for="(item,index) in pro_list" :key="index">
        {{ item.name }} - {{ item.price }}
        <button @click="del(index)">
          删除
        </button>
      </li>
    </ul> -->
    <div class="product">
          <div class="pro_title">
              猜你喜欢
          </div>
          <div class="pro_list">
              <div class="list" v-for="item in pro_list" :key="item.ID"
              @click="$router.push(`/product/detail?admin_id=${item.admin_id}&product_id=${item.ID}`)"
              >
                  <div class="img">
                      <img :src="item.duck_img" alt="">
                  </div>
                  <div class="title">
                      {{ item.duck_name }}
                  </div>
                  <div class="price">
                      <div class="now_price">
                          <span>
                              ￥
                          </span>
                          {{ item.duck_min_price }}
                      </div>
                      <div class="no_price">
                          <span>
                              ￥
                          </span>
                          {{ item.duck_max_price }}
                      </div>
                  </div>
                  <div class="count">
                      <div class="hot">
                          销量: {{ item.duck_hot > 1000 ? '1000+' : item.duck_hot }}
                      </div>
                      <div class="look">
                          库存: {{ item.num > 999 ? '999+' : item.num }}
                      </div>
                  </div>
              </div>
          </div>
      </div>
  </div>
</template>

<script>
// import mixin from '@/utils/mixins' 
import { getHome } from "@/api";
export default {
  methods:{
    // del(index){
    //   // this.$store.state.pro_list = index;
    //   // 触发store里面的proListChange函数
    //   // this.$store.commit('proListChange',index)
    //   this.$store.dispatch('ListChange',index)
    // }
  },
  // mixins: [mixin],
  data(){
    return {
      pro_list: []
    }
  },
  created(){
    // this.pro_list = this.$store.state.pro_list;
    // console.log(this.pro_list);
    // console.log(this.msg);
    // this.hello();
    getHome({
      admin_id: 125
    }).then(res => {
      this.pro_list = res.data.result.product_list;
    })
  }
}
</script>

<style lang="scss" scoped>
.product{
    width: 92%;
    margin-left: 4%;
    margin-top: 20px;
    .pro_title{
        height: 45px;
        line-height: 45px;
        font-weight: bold;
        font-size: 18px;
    }
    .pro_list{
        width: 100%;
        display: flex;
        justify-content: space-between;
        flex-wrap: wrap;
        .list{
            width: 48%;
            min-height: 290px;
            box-sizing: border-box;
            padding: 2%;
            background-color: #fff;
            .img{
                width: 100%;
                img{
                    width: 100%;
                    border-radius: 5px;
                }
            }
            .title{
                height: 45px;
                box-sizing: border-box;
                padding: 5px 0;
                line-height: 20px;
                overflow : hidden;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
            }
            .price{
                display: flex;
                height: 20px;
                div{
                    font-size: 17px;
                    font-weight: bold;
                    span{
                        font-size: 12px;
                    }
                }
                .now_price{
                    color:#ff0000;
                }
                .no_price{
                    font-size: 13px;
                    text-decoration: line-through;
                    margin-left: 15px;
                    color: #999;
                    line-height: 25px;
                }
            }
            .count{
                padding-top: 5px;
                height: 20px;
                display: flex;
                font-size: 12px;
                color: #a39e9e;
                justify-content: space-between;
            }
        }
    }
}
</style>